program main
    implicit none
    character(len=5) :: p='word!',t
    call secret(p,t)
    write(*,*)t
end program

subroutine secret(s,t)
    implicit none
    character(len=5) :: s
    character(len=5) :: t
    character(len=52) :: slist='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
    character(len=52) :: klist='zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA'
    integer :: l,i
    do i=1,len(s)
        l=index(slist,s(i:i))
        if(l>0)then
            t(i:i)=klist(l:l)
        else
            t(i:i)=s(i:i)
        end if
    end do
end subroutine
